package com.intel.factorytest.activity;

import android.app.Activity;
import com.intel.factorytest.R;
import android.widget.Button;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

public class ResetPhoneActivity extends Activity{

    Button resetPhone;
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.reset_phone_layout);
        resetPhone = (Button)findViewById(R.id.reset_phone);
        resetPhone.setOnClickListener(mFinalClickListener);
    }

    private Button.OnClickListener mFinalClickListener = new Button.OnClickListener() {

        public void onClick(View v) {
            // sendBroadcast(new Intent("android.intent.action.MASTER_CLEAR"));
            doMasterClear();
        }
    };

    private void doMasterClear() {
        Intent intent = new Intent(Intent.ACTION_FACTORY_RESET);
        intent.setPackage("android");
        intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
        intent.putExtra(Intent.EXTRA_REASON, "CIT MasterClear");
        intent.putExtra(Intent.EXTRA_WIPE_EXTERNAL_STORAGE, true);
        intent.putExtra(Intent.EXTRA_WIPE_ESIMS, true);
        sendBroadcast(intent, "permission.CIT_ALLOW_INCOMING");
    }
}
